﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PortChat
{
    //bit stuffer
    class BitStuffer
    {
        //bitstuffing: 11111 -> 111110
        public String stuff(String strFrames)
        {
            return strFrames.Replace("11111", "111110");
        }

        //reverse bitstuffing: 111110 -> 11111
        public String deStuff(String strFrames)
        {
            return strFrames.Replace("111110","11111");
        }

        //destuff a list of stuffed frames
        public List<String> deStuff(List<String> lstStuffedFrames)
        {
            List<String> lstFrames = new List<String>();
            foreach (String myStuffedFrame in lstStuffedFrames)
            {
                lstFrames.Add(deStuff(myStuffedFrame));
            }
            return lstFrames;
        }
    }
}
